const puppeteer = require('puppeteer')


;(async () => {
  const browser = await puppeteer.launch({
    slowMo: 500,
    devtools: true
  });
  // 创建一个页面
  const page = await browser.newPage();
  // 去哪个页面
  await page.goto('http://image.baidu.com');
  await page.focus('#kw')
  await page.keyboard.sendCharacter('saber 1920 * 1080');
  await page.click('.s_newBtn')

  await page.on('load', async function() {
    const sources = await page.evaluate(async () => {
      const images = document.getElementsByClassName("main_img")
      return [...images].map(img => img.src)
    })
    console.log(sources)
  })
  // 关闭页面
  // await browser.close();
})()